//
//  UIView+wgXib.m
//  WGTool
//
//  Created by czw on 2022/8/19.
//

#import "UIView+wgXib.h"

@implementation UIView (wgXib)

+ (UINib *)wg_nib
{
    return [self wg_nibWithName:NSStringFromClass([self class])];
}

+ (UINib *)wg_nibWithName:(NSString *)name
{
    return [UINib nibWithNibName:name bundle:[NSBundle mainBundle]];
}

+ (instancetype)wg_loadFromNib
{
    return [self wg_loadFromNib:NSStringFromClass([self class])];
}

+ (instancetype)wg_loadFromNib:(NSString *)nibName
{
    return [[[self wg_nibWithName:nibName] instantiateWithOwner:nil options:nil] firstObject];
}

+ (instancetype)wg_loadFromNibWithFrame:(CGRect)frame
{
    UIView * nibView = [self wg_loadFromNib];
    nibView.frame = frame;
    return nibView;
}

@end
